<? if ($items): ?>

  <? if (tsAdminDash::getProperty('menu-aligment') == 'vertical'): ?>

    <div id="accordion" class="ui-accordion ui-widget ui-helper-reset" role="tablist">
      <h3 class="ui-accordion-header ui-helper-reset ui-state-active ui-corner-top" role="tab" aria-expanded="true" tabindex="0">
        <span class="icon ui-icon-triangle-1-s"></span>
        <a href="#" tabindex="-1" class="">Menu</a>
      </h3>
      <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active" style="height: auto; ">
        <? include_partial('tsAdminDash/menu_list', array('items' => $items)) ?>
      </div>
    </div>
    <script type="text/javascript">
      $("#accordion").accordion();
    </script>

  <? else: ?>

    <div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
      <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
        <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tabs-0">Menu</a></li>
      </ul>
        <div id="tabs-0" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
          <? include_partial('tsAdminDash/menu_list', array('items' => $items)) ?>
        </div>
    </div>
    <script type="text/javascript">
      $("#tabs").tabs();
    </script>

  <? endif ?>

<? elseif ($cats): ?>

  <? if (tsAdminDash::getProperty('menu-aligment') == 'vertical'): ?>

    <div id="accordion" class="ui-accordion ui-widget ui-helper-reset">
    <? $i=0; $active=0; ?>
    <? foreach ($cats as $name => $cat): $i++; ?>
      <? $is_active = tsAdminDash::isOneActive($cat['items']); ?>
      <? if ($is_active) $active = $i-1; ?>
      <? $nodes = trim(get_partial('tsAdminDash/menu_list', array('items' => $cat['items'])))  ?>
      <? if ($nodes && tsAdminDash::hasPermission($cat, $sf_user)): ?>
      <h3 class="ui-accordion-header ui-helper-reset<? echo (($is_active)? ' ui-state-active ui-corner-top': ' ui-state-default ui-corner-all'); ?>">
        <span class="<? echo (($is_active)? 'ui-icon ui-icon-triangle-1-s': 'ui-icon ui-icon-triangle-1-e'); ?>"></span>
        <a href="#"><?=$name ?></a>
      </h3>
      <div class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom<? echo (($is_active)? ' ui-accordion-content-active': ''); ?>">
        <?=$nodes ?>
      </div>
      <? endif; ?>
    <? endforeach; ?>
    </div>
    <script type="text/javascript">
      $("#accordion h3 span").remove();
      $("#accordion").accordion({
        autoheight: false
      });
      $("#accordion").accordion("activate", <? echo $active; ?>);
    </script>

  <? else: ?>

    <div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
      <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
      <? $i=0; ?>
      <? foreach ($cats as $name => $cat): $i++; ?>
        <? $is_active = tsAdminDash::isOneActive($cat['items']); ?>
        <? $nodes = trim(get_partial('tsAdminDash/menu_list', array('items' => $cat['items'])))  ?>
        <? if ($nodes && tsAdminDash::hasPermission($cat, $sf_user)): ?>
        <li class="ui-state-default ui-corner-top<? echo (($is_active)? ' ui-tabs-selected ui-state-active': ''); ?>"><a href="#tabs-<?=$i?>"><?=$name ?></a></li>
        <? endif; ?>
      <? endforeach; ?>
      </ul>
      <? $i=0; ?>
      <? foreach ($cats as $name => $cat): $i++; ?>
        <? $is_active = tsAdminDash::isOneActive($cat['items']); ?>
        <? $nodes = trim(get_partial('tsAdminDash/menu_list', array('items' => $cat['items'])))  ?>
        <? if ($nodes && tsAdminDash::hasPermission($cat, $sf_user)): ?>
        <div id="tabs-<?=$i?>" class="ui-tabs-panel ui-widget-content ui-corner-bottom<? echo (($is_active)? '': ' ui-tabs-hide'); ?>">
          <?=$nodes ?>
        </div>
        <? endif; ?>
      <? endforeach; ?>
    </div>
    <script type="text/javascript">
      $("#tabs").tabs();
    </script>

  <? endif ?>

<? else: ?>

  <div class="ui-widget">
    <div style="padding: 0pt 0.7em;" class="ui-state-error ui-corner-all">
      <p><span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert"></span>
      <strong>Error:</strong> Plugin not configured.  Please see documentation.</p>
    </div>
  </div>
  
<? endif; ?>